<template>
    <el-container style="height: calc(100vh - 135px)">
        <el-header class="title">
            <el-form @submit.native.prevent :inline="true">
                <el-form-item label="采购商家:">
                    <v-buyer-merchant v-model="buyerMerchantId"></v-buyer-merchant>
                </el-form-item>
                <el-form-item label="查询日期:">
                    <el-date-picker
                        v-model="queryDate"
                        type="date"
                        placeholder="选择日期"
                        value-format="yyyy-MM-dd">
                    </el-date-picker>
                </el-form-item>
                <el-form-item>
                    <el-button @click="handleCheck" type="primary">查询</el-button>
                </el-form-item>
            </el-form>
            <el-row>
                <el-col :span="24">
                    <el-button @click="initPriceDialog" type="primary">定价初始化</el-button>
                    <el-button @click="updateShopPriceDialog" type="primary" style="margin:0 15px;">更新零售价</el-button>
                    <el-button @click="dialogFormVisible = true" type="primary">增加定价</el-button>
                    <a id="exportBtn" @click="exportExcel" style="margin:0 15px;">
                      <el-button type="primary">导出excel</el-button>
                    </a>
                    <el-button @click="dialogCopy = true" type="primary">复制商家定价</el-button>
                </el-col>
                <el-dialog title="复制商家定价" :visible.sync="dialogCopy">
                  <el-form :model="copy">
                    <el-form-item label="选择来源采购商家" label-width="140px" required >
                      <v-buyer-merchant v-model="copy.merchantId"></v-buyer-merchant>
                    </el-form-item>
                    <el-form-item label="来源定价时间" label-width="140px" required>
                      <el-date-picker
                        v-model="copy.oldDate"
                        :clearable="false"
                        :editable="false"
                        type="daterange"
                        format="yyyy-MM-dd"
                        value-format="yyyy-MM-dd"
                        range-separator="至"
                        start-placeholder="开始日期"
                        end-placeholder="结束日期">
                      </el-date-picker>
                    </el-form-item>
                    <el-form-item label="选择目标采购商家" label-width="140px" required >
                      <v-buyer-merchant v-model="copy.newMerchantId"></v-buyer-merchant>
                    </el-form-item>
                    <el-form-item label="目标定价时间" label-width="140px" required>
                      <el-date-picker
                        v-model="copy.newDate"
                        :clearable="false"
                        :editable="false"
                        type="daterange"
                        format="yyyy-MM-dd"
                        value-format="yyyy-MM-dd"
                        range-separator="至"
                        start-placeholder="开始日期"
                        end-placeholder="结束日期">
                      </el-date-picker>
                    </el-form-item>
                  </el-form>
                  <div slot="footer" class="dialog-footer">
                    <el-button @click="dialogCopy = false">取消</el-button>
                    <el-button type="primary" @click="addCopy">复制</el-button>
                  </div>
                </el-dialog>
                <el-dialog title="增加定价" :visible.sync="dialogFormVisible">
                  <el-form :model="form">
                    <el-form-item label="商品名称:" prop="goodsName" label-width="15%">
                      <el-select
                        clearable
                        filterable
                        default-first-option
                        v-model="selectGoods.goodsName"
                        remote :remote-method="searchGoodsByName(selectGoods)"
                        @change="onGoodsSelectChange($event, selectGoods)"
                        placeholder="请输入商品名称"
                        style="width: 40% !important">
                        <el-option
                          v-for="item in selectGoods.goodsList"
                          :key="item.id" :label="item.goodsName"
                          :value="item.id">
                        </el-option>
                      </el-select>
                      <!--<el-button type="text" @click="showGoodsDialog()" style="width: 10%">所有商品</el-button>-->
                    </el-form-item>
                    <el-form-item label="规格:" prop="goodsId" label-width="15%">
                      <el-select class="form-field"
                                 v-model="selectGoods.goodsId"
                                 @change="onModelSelectChange($event, selectGoods)"
                                 placeholder="请选择"
                                 style="width: 40% !important">
                        <el-option
                          v-for="item in selectGoods.goodsModelList"
                          :key="item.id"
                          :label="item.modelName+' /单位:'+item.modelUnit"
                          :value="item.id">
                        </el-option>
                      </el-select>
                    </el-form-item>
                    <el-form-item label="定价" label-width="15%" required>
                      <el-input v-model="form.price" type="number" oninput="if(value.length>8)value=value.slice(0,8)" autocomplete="off" style="width: 40%"></el-input>
                    </el-form-item>
                    <el-form-item label="开始时间" label-width="15%" required>
                      <el-date-picker
                        v-model="form.purchaseDate"
                        :clearable="false"
                        :editable="false"
                        type="daterange"
                        format="yyyy-MM-dd"
                        value-format="yyyy-MM-dd"
                        range-separator="至"
                        start-placeholder="开始日期"
                        end-placeholder="结束日期">
                      </el-date-picker>
                    </el-form-item>
                    <el-form-item label="选择采购商家" label-width="15%" required >
                      <el-select
                        class="bms_select"
                        filterable
                        clearable
                        default-first-option
                        v-model="form.merchantId"
                        @change="optionChange"
                        style="max-width: 350px"
                        value-key="merchantId"
                        placeholder="请选择">
                        <el-option
                          v-for="item in buyerMerchantList"
                          :key="item.merchantId"
                          :label="item.merchantName"
                          :value="item.merchantId">
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-form>
                  <div slot="footer" class="dialog-footer">
                    <el-button @click="dialogFormVisible = false">取消</el-button>
                    <el-button type="primary" @click="confirm">添加</el-button>
                  </div>
                </el-dialog>
                <!--<el-col :span="6"></el-col>-->
                <!--<el-col :span="10">-->
                    <!--<template v-show="categoryList.length > 0">-->
                        <!--查找商品:-->
                      <!--<div style="display: inline-block;">-->
                        <!--<el-select-->
                          <!--v-model="viewGoods"-->
                          <!--filterable-->
                          <!--@change="lookUp"-->
                          <!--placeholder="请选择">-->
                          <!--<el-option-group-->
                            <!--v-for="group in categoryList"-->
                            <!--:key="group.categoryId"-->
                            <!--:label="group.categoryName">-->
                            <!--<el-option-->
                              <!--v-for="item in group.goodsList"-->
                              <!--:key="item.id"-->
                              <!--:label="item.goodsName +'-'+ item.modelName"-->
                              <!--:value="item.id">-->
                            <!--</el-option>-->
                          <!--</el-option-group>-->
                        <!--</el-select>-->
                      <!--</div>-->
                    <!--</template>-->
                <!--</el-col>-->
            </el-row>
        </el-header>
        <el-main class="content">
            <el-container>
                <el-main>
                    <div class="cont-item">
                        <table border="1" :v-loading="loading">
                            <caption style="background-color: white">{{pmName}}</caption>
                            <tbody>
                            <tr>
                                <td colspan="1" class="blod bc-yellow">采购商家名称</td>
                                <td colspan="1">{{head.merchantName}}</td>
                                <td class="blod bc-yellow">采购人</td>
                                <td class="print-hidden" colspan="2">{{head.contact}}</td>
                                <td class="blod bc-yellow">有效期</td>
                                <td colspan="2">{{startDate}} 至 {{endDate}}
                                    <!--<el-button type="text" @click="goToNext">下一阶段报价</el-button>-->
                                </td>
                                <td class="blod bc-yellow">联系电话</td>
                                <td colspan="2">{{head.telephone}}</td>
                            </tr>
                            <tr>
                                <td class="blod bc-yellow" colspan="1">地址</td>
                                <td colspan="10">{{head.address}}</td>
                            </tr>
                            <tr>
                                <td colspan="11">&nbsp;</td>
                            </tr>
                            <template v-for="(category,index) in categoryList">
                                <tr class="blod bc-yellow" v-key="index">
                                    <td class="blod bc-yellow">序号</td>
                                    <td class="blod bc-yellow">分类名称</td>
                                    <td class="blod bc-yellow">商品编号</td>
                                    <td class="blod bc-yellow">商品名称</td>
                                    <td class="blod bc-yellow">规格</td>
                                    <td class="blod bc-yellow">市场价</td>
                                    <td class="blod bc-yellow" style="min-width: 200px">采购价</td>
                                    <td class="blod bc-yellow">单位</td>
                                    <td class="blod bc-yellow">开始时间</td>
                                    <td class="blod bc-yellow">结束时间</td>
                                    <td class="blod bc-yellow">操作</td>
                                </tr>
                                <tr v-for="(goods,inx) in category.goodsList" v-key="goods.id">
                                    <td>{{inx + 1}}</td>
                                    <td>{{goods.categoryName}}</td>
                                    <td>{{goods.goodsModelSn}}</td>
                                    <td>{{goods.goodsName}}</td>
                                    <td>{{goods.modelName}}</td>
                                    <td>{{goods.marketPrice}}</td>
                                    <td>
                                        <!--{{goods.purchasePrice}}-->
                                        <el-input-number
                                            @change="handlePriceChange(goods)"
                                            v-model="goods.purchasePrice">
                                        </el-input-number>
                                    </td>
                                    <td>{{goods.unit}}</td>
                                    <td>{{goods.startDate}}</td>
                                    <td>{{goods.endDate}}</td>
                                    <td><el-button @click="delTd(goods)" type="danger" size="small" :disabled="goods.isdisabledFn">删除定价</el-button></td>
                                </tr>
                                <tr v-key="index">
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td>-</td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                </tr>
                            </template>
                            </tbody>
                        </table>
                      <table border="1" :v-loading="loading" id="exportTable" style="display:none">
                        <caption style="background-color: white">{{pmName}}</caption>
                        <tbody>
                        <tr>
                          <td colspan="1" class="blod bc-yellow">采购商家名称</td>
                          <td colspan="1">{{head.merchantName}}</td>
                          <td class="blod bc-yellow">采购人</td>
                          <td class="print-hidden" colspan="2">{{head.contact}}</td>
                          <td class="blod bc-yellow">有效期</td>
                          <td colspan="2">{{startDate}} 至 {{endDate}}
                          </td>
                          <td class="blod bc-yellow">联系电话</td>
                          <td colspan="2">{{head.telephone}}</td>
                        </tr>
                        <tr>
                          <td class="blod bc-yellow" colspan="1">地址</td>
                          <td colspan="10">{{head.address}}</td>
                        </tr>
                        <tr>
                          <td colspan="11">&nbsp;</td>
                        </tr>
                        <template v-for="(category,index) in categoryList">
                          <tr class="blod bc-yellow" v-key="index">
                            <td class="blod bc-yellow">序号</td>
                            <td class="blod bc-yellow">分类名称</td>
                            <td class="blod bc-yellow">商品编号</td>
                            <td class="blod bc-yellow">商品名称</td>
                            <td class="blod bc-yellow">规格</td>
                            <td class="blod bc-yellow">市场价</td>
                            <td class="blod bc-yellow" style="min-width: 200px">采购价</td>
                            <td class="blod bc-yellow">单位</td>
                            <td class="blod bc-yellow">开始时间</td>
                            <td class="blod bc-yellow">结束时间</td>
                          </tr>
                          <tr v-for="(goods,inx) in category.goodsList" v-key="goods.goodsModelSn">
                            <td>{{inx + 1}}</td>
                            <td>{{goods.categoryName}}</td>
                            <td>{{goods.goodsModelSn}}</td>
                            <td>{{goods.goodsName}}</td>
                            <td>{{goods.modelName}}</td>
                            <td>{{goods.marketPrice}}</td>
                            <td>
                              {{goods.purchasePrice}}
                            </td>
                            <td>{{goods.unit}}</td>
                            <td>{{goods.startDate}}</td>
                            <td>{{goods.endDate}}</td>
                          </tr>
                          <tr v-key="index">
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                          </tr>
                        </template>
                        </tbody>
                      </table>


                    </div>
                </el-main>
            </el-container>
        </el-main>
        <el-dialog title="选项列表" :visible.sync="showDialog">
            <el-form
                :model="dialogForm"
                @submit.native.prevent
            >
                <el-form-item>
                    <span v-show="dialogShowType == 'init'">初始化采购商家采购价</span>
                    <span v-show="dialogShowType == 'update'">更新零售店铺市场价</span>
                </el-form-item>
                <el-form-item v-show="dialogShowType == 'init'">
                    <v-buyer-merchant v-model="dialogForm.buyerMerchantId"></v-buyer-merchant>
                </el-form-item>
                <el-form-item label="定价时间段">
                    <el-date-picker
                        v-model="dialogForm.purchaseDate"
                        :clearable="false"
                        :editable="false"
                        type="daterange"
                        format="yyyy-MM-dd"
                        value-format="yyyy-MM-dd"
                        range-separator="至"
                        start-placeholder="开始日期"
                        end-placeholder="结束日期">
                    </el-date-picker>
                </el-form-item>
                <el-form-item label="下调价格比例" v-show="dialogShowType == 'init'">
                    <el-input v-model="dialogForm.rate" style="max-width: 250px" placeholder="输入小数"></el-input>
                </el-form-item>
                <el-form-item >
                    <el-button type="primary" @click="initPriceSubmit" v-show="dialogShowType == 'init'">开始初始化</el-button>
                    <el-button type="primary" @click="updateShopPriceSubmit" v-show="dialogShowType == 'update'">开始更新价格</el-button>
                </el-form-item>
            </el-form>
        </el-dialog>
    </el-container>
</template>

<script>
    import {Loading} from 'element-ui';
    import excel from "@/util/pds/exportExcel.js";
    import Request from "../../request.js";
    import vBuyerMerchant from "../../../../components/pds/common/buyer_merchant_select";
    import {getStore, setStore} from "@/util/store";
    export default {
        data: function () {
            return {
                request: new Request(),
                activeName: "first",
                buyerMerchantId: "",
                buyerList: [],
                queryDate: this.nowDate(),
                head: {},
                endDate: "",
                startDate: "",
                deliveryTime: this.nowDate(),
                pmName: getStore({name: "pmName"}),
                categoryList: [],
                loading: true,
                viewGoods: "",
                showDialog: false,
                dialogShowType: "init",
                dialogForm: {
                    shopId: "",
                    buyerMerchantId: "",
                    purchaseDate: [this.nowDate(), this.nowDate()],
                    rate: 0,
                },
                dialogFormVisible:false,
                form:{
                  pmId:getStore({name: "pmId"}),
                  merchantId:'',
                  purchaseDate: [this.nowDate(), this.nowDate()],
                  modelId:'',
                  price:''
                },
                selectGoods: {
                  goodsName: '',
                  goodsList: [],
                  goodsId: '',
                  goodsModelList: []
                },
                buyerMerchantList: [],
                dialogCopy:false,
                copy:{
                  pmId:getStore({name: "pmId"}),
                  merchantId:'',
                  newMerchantId:'',
                  oldDate: [this.nowDate(), this.nowDate()],
                  newDate: [this.nowDate(), this.nowDate()],
                },
                flag:1
            }
        },
        components: {
            vBuyerMerchant
        },
        watch: {},
        created() {
            this.lookUp();
            this.getBuyerMerchantList()
        },
        computed: {},
        methods: {
            // 查询采购商家 列表
            getBuyerMerchantList() {
              this.request.getBuyerMerchantList().then(res => {
                if (res.code == 200) {
                  if(res.ext.count > 0){
                    this.buyerMerchantList = res.ext.merchantList;
                  }
                }else{
                  this.$message.warning("未查询到采购商家列表：" + res.msg)
                }
              })
            },
            // 搜索商品
            searchGoodsByName(row) {
              // 将row信息传入
              let _this = this;
              return function (searchValue) {
                if (searchValue !== '') {
                  console.log('time', searchValue);
                  let params = {
                    goodsName: searchValue,
                  }
                  params.pageNo = 100
                  params.pageSize = 100
                  params.goodsName = searchValue
                  _this.request.getGoodsList(params).then(res => {
                    if (res.code == 200) {
                      _this.$set(row, 'goodsList', res.ext.list);
                    } else if (res.code == '983') {
                      _this.goodsList = []
                    } else {
                      _this.$message.error('请求失败')
                    }
                  })
                }
              }
            },
            //选择商品
            onGoodsSelectChange(e, row) {
              if(e){
                let selectedGoods = row.goodsList.filter(item => item.id === e)[0]
                row.goodsModelList = selectedGoods.goodsModelList
                this.$set(row, 'goodsName', selectedGoods.goodsName)
                this.onModelSelectChange(selectedGoods.goodsModelList[0].id, row)
                row.goodsModel = ''
              }else{
                // 清空选项时
                this.$set(row, 'goodsId', '');
                row.goodsId = '';
              }
            },
            //选择规格
            onModelSelectChange(e, row) {
              let selectedModel = row.goodsModelList.filter(item => item.id === e)[0]
              this.form.modelId = selectedModel.id;
            },
            //复制定价
            addCopy(){
              let param = {
                pmId:getStore({name: "pmId"}),
                merchantId:this.copy.merchantId,
                beginStartDate : this.copy.oldDate[0],
                beginEndDate : this.copy.oldDate[1],
                newMerchantId:this.copy.newMerchantId,
                startDate : this.copy.newDate[0],
                endDate : this.copy.newDate[1],
              };
              if(param.merchantId == ''){
                this.$message.error("请选择来源商家");
                return false;
              }
              if(param.newMerchantId == ''){
                this.$message.error("请选择目标商家");
                return false;
              }
              if(this.flag != 1){
                this.$message.error("请勿重复点击");
                return false;
              }
              this.flag = 0;
              this.request.copyPrice(param).then(res =>{
                if(res.code === 200){
                  this.$message.success(res.msg);
                  this.dialogCopy= false;
                  this.flag = 1;
                }else{
                  this.$message.error(res.msg);
                  var _this = this;
                  setTimeout(function () {
                    _this.flag = 1;
                  },1000)
                }
              });
            },
            //新增市场行情
            confirm(){
              let param = {
                  pmId:getStore({name: "pmId"}),
                  merchantId:this.form.merchantId,
                  startDate : this.form.purchaseDate[0],
                  endDate : this.form.purchaseDate[1],
                  modelId:this.form.modelId,
                  price:this.form.price,
              };
              if(param.modelId == ''){
                this.$message.error("请选择商品");
                return false
              }
              if(param.startDate == ''){
                this.$message.error("请选择开始时间");
                return false
              }
              if(param.endDate == ''){
                this.$message.error("请选择结束时间");
                return false
              }
              if(param.price == ''){
                this.$message.error("请输入价格");
                return false
              }
              if(param.merchantId == ''){
                this.$message.error("请选择采购商家");
                return false
              }
              this.request.addPrice(param).then(res =>{
                if(res.code === 200){
                  this.$message.success("新增成功");
                  this.dialogFormVisible = false;
                  this.form = {
                    pmId:getStore({name: "pmId"}),
                      merchantId:'',
                      startDate:'',
                      endDate:'',
                      modelId:'',
                      price:''
                  };
                  this.selectGoods = {
                    goodsName: '',
                      goodsList: [],
                      goodsId: '',
                      goodsModelList: []
                  };
                }else{
                  this.$message.error("新增失败")
                }
              });
            },
            //删除定价
            delTd(goods){
              this.$confirm('确认删除吗?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning',
                center: true
              }).then(() => {
                let params = {
                  pmId:getStore({name: "pmId"}),
                  priceId:goods.id
                }
                this.request.deletePrice(params).then(res => {
                  if (res.code === 200) {
                    goods.isdisabledFn = true;
                    this.$message.success(res.msg);
                    //this.queryList();
                  } else {
                    this.$message.warning(res.msg);
                  }
                })
              }).catch(() => {

              });
            },
            initPriceSubmit(){
                this.showDialog = false;
                let params = {
                    buyerMerchantId: this.dialogForm.buyerMerchantId,
                    startDate: this.dialogForm.purchaseDate[0],
                    endDate: this.dialogForm.purchaseDate[1],
                    rate: 0 - this.dialogForm.rate
                };
                if(!(params.buyerMerchantId && params.startDate && params.endDate)){
                    this.$message.warning("必选项未选择");
                    return;
                }
                if(!(params.rate>-1)){
                    this.$message.warning("下调价格比例有误");
                    return;
                }
                this.request.initPrice(params).then(res => {
                    if (res.code === 200) {
                        this.$message.success(res.msg);
                    } else {
                        this.$message.warning(res.msg);
                    }
                }).catch(err => {
                    this.$message.warning(err);
                })
            },
            updateShopPriceSubmit(){
                this.showDialog = false;
                let params = {
                    buyerMerchantId: getStore({name: "pmId"}),
                    startDate: this.dialogForm.purchaseDate[0],
                    endDate: this.dialogForm.purchaseDate[1]
                };
                if(!(params.buyerMerchantId && params.startDate && params.endDate)){
                    this.$message.warning("必选项未选择");
                    return;
                }
                this.request.updatePriceToPmShop(params).then(res => {
                    if (res.code === 200) {
                        this.$message.success(res.msg);
                    } else {
                        this.$message.warning(res.msg);
                    }
                }).catch(err => {
                    this.$message.warning(err);
                })
            },
            initPriceDialog() {
                // 平台商家采购商定价初始化
                this.dialogShowType = "init";
                this.showDialog = true;
            },
            updateShopPriceDialog() {
                // 平台商家店铺零售价更新
                this.dialogShowType = "update";
                this.showDialog = true;
            },
            lookUp() {
                // 查找商品的锚点位置
                let id = this.viewGoods;
                console.log("viewGoods", id);
                if (id) {
                    let ele = document.getElementById(id);
                    console.warn("ele", ele);
                    if(ele){
                        ele.scrollIntoView(true);
                    }
                    // document.querySelector("#"+id).style.backgroundColor = "#FFC000";
                }
            },
            nowDate() {
                let d = new Date();
                return d.getFullYear() + "-" + (d.getMonth() + 1) + "-" + d.getDate();
            },
            handleCheck() {
                switch (this.activeName) {
                    case "first":
                        this.queryList()
                        break;

                    default:
                        break;
                }
            },
            handlePriceChange(item) {
                this.updateGoodsPrice(item);
            },
            exportExcel() {
                if (this.categoryList.length) {
                    let excelName = this.pmName + "采购商定价单"+this.startDate+"_"+this.endDate+".xls";
                    excel.getExcel("exportTable", "采购商定价", excelName, "exportBtn")
                } else {
                    this.$message.warning("当前无表格数据");
                }
            },
            // handleClick(){
            //     this.queryList()
            // },
            // goToNext(){
            //     let d =  +new Date( this.endDate)
            //     d += 24 * 60 * 60 * 1000;
            //     d = new Date(d);
            //     let str = d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
            //     this.date = str;
            //     this.queryList()
            // },
            // // 处理应用到某个商家
            // handleDest(item, index){
            //     let idx;
            //     this.buyerList.forEach( (ele,indx) => {
            //         if( ele.id == this.buyerId){
            //             idx = indx
            //         }
            //     })
            //     console.log( index)
            //     console.log(this.buyerList[idx].buyerName)
            //     this.$confirm(`您确认将您对${this.buyerList[idx].buyerName}下${this.startDate}日到${this.endDate}日的报价上升${item.rate}的比率应用到${item.buyerName}？`)
            //     .then(res => {
            //         this.copyGoodsByBuyer({destBuyerId:item.id,
            //         queryDate: this.deliveryTime,
            //         rate: item.rate,
            //         })
            //     })
            //
            // },
            // // 查询采购商列表
            // fetchBuyerList(){
            //     this.request.fetchBuyerList().then( res => {
            //         if(res.code == 200){
            //             this.buyerList = res.ext;
            //         }else{
            //             this.$message.warning(res.msg)
            //         }
            //
            //     }).catch(err => {
            //         this.$message.warning(err)
            //     })
            // },
            // 查询商品列表
            queryList() {
                let params = {
                    buyerMerchantId: this.buyerMerchantId,
                    queryDate: this.queryDate
                };
                if (!(params.buyerMerchantId && params.queryDate)) {
                    this.$message.warning("请选择采购商家和日期");
                    return;
                }
                let loadingInstance = Loading.service({fullscreen: true});
                this.request.queryGoodsList(params).then(res => {
                    if (res.code === 200) {
                        this.head = res.ext.pdsBuyer;
                        res.ext.categoryList.forEach((item)=>{
                          item.goodsList.forEach((chiln)=>{
                            chiln.isdisabledFn = false;
                          })
                        })
                        this.categoryList = res.ext.categoryList;
                        this.startDate = res.ext.startDate;
                        this.endDate = res.ext.endDate;
                        this.form.startDate = res.ext.startDate;
                        this.form.endDate = res.ext.endDate;
                        this.form.merchantId = this.buyerMerchantId;
                        this.loading = false;
                    } else {
                        this.$message.warning(res.msg)
                        this.loading = false;
                    }
                    loadingInstance.close()
                }).catch(err => {
                    this.$message.warning(err)
                    this.loading = false;
                    loadingInstance.close()
                })
            },
            // 更新商品报价
            updateGoodsPrice(goods) {
                let params = {
                    id: goods.id,
                    price: goods.purchasePrice
                };
                this.request.updateGoodsPrice(params).then(res => {
                    if (res.code === 200) {
                        this.$message.success(res.msg);
                    } else {
                        this.$message.warning(res.msg);
                    }
                }).catch(err => {
                    this.$message.warning(err);
                })
            },
            // //
            // copyGoodsByBuyer(params = {}){
            //     params.buyerId = this.buyerId;
            //     this.request.copyGoodsByBuyer(params).then(res => {
            //         if( res.code === 200){
            //             this.$message.success(res.msg)
            //         }else{
            //             this.$message.warning(res.msg)
            //         }
            //     })
            // }
        }
    }
</script>

<style scoped lang="scss">
    .el-select{
      width: 200px;
    }
    .el-header, .el-main, .el-footer {
        margin: 5px;
    }

    .title {
        background-color: white;
        padding: 10px;
        margin-bottom: 20px;
        min-height: 120px;
    }

    .to-left {
        text-align: left;
    }

    caption {
        font-size: 24px;
    }

    .blod {
        font-weight: 600;
    }

    .padRight {
        text-align: center;
        margin: 0 auto;
        // height: 100%;
        // transform: rotateZ(90deg);
        writing-mode: vertical-lr; /*从左向右 从右向左是 writing-mode: vertical-rl;*/
        writing-mode: tb-lr;
        font-size: 14px;
        color: #bbb;
    }

    .padRight-cons {
        text-align: center;
        margin: 0 auto;
        writing-mode: vertical-lr; /*从左向右 从右向左是 writing-mode: vertical-rl;*/
        writing-mode: tb-lr;
        font-size: 14px;
    }

    table {
        border-spacing: 0px;
        // border: 0.5px;
        td {
            border: 0.5px;
        }
    }



    .bc-yellow {
        background-color: rgb(255, 192, 0)
    }

    td, th {
        // border: 0 1px 1px 0;
        padding: 0;
        max-width: 150px;
    }

    caption {
        padding: 8px;
        background-color: rgb(112, 173, 71);
        font-weight: 800;
    }

    table {
        width: 100%;
    }

    table.gridtable {
        font-family: verdana, arial, sans-serif;
        font-size: 11px;
        color: #333333;
        border-width: 1px;
        border-color: #666666;
        border-collapse: collapse;
    }

    table th {
        border-width: 1px;
        padding: 8px;
        border-style: solid;
        border-color: #666666;
        background-color: #dedede;
    }

    table td {
        text-align: center;
        line-height: 100%;
        border: 1px;
        padding: 8px;
        border-style: solid;
        border-color: #666666;
        background-color: #ffffff;
    }

</style>
